<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>选择银行卡</title>
    <link rel="stylesheet" href="css/amazeui.min.css" />
    <link rel="stylesheet" href="css/app.css" />
    <link rel="stylesheet" type="text/css" href="css/pageCode.css">
    <script src="assets/js/jquery.min.js" type="text/javascript"></script>
    <script src="js/amazeui.min.js" type="text/javascript"></script>
    <style>
        body {
            max-width: 640px;
            margin: 0 auto;
            font-size: 10px;
            background: #F2F3F8;
        }

        * {
            box-sizing: border-box;
        }

        [class*=am-u-] {
            padding: 0;
        }
    </style>
</head>

<body>
    <!--头部-->
    <header class="am-u">
        <div class="am-u-sm-12 head_nav" style="margin:0;">
            <div class="am-u-sm-2 am-vertical-align" style="text-align: center;">
                <a href="mine.html">
                    <img src="img/return@2x.png" class="am-vertical-align-middle" alt="" />
                </a>
            </div>
            <div class="am-u-sm-8 head_text">
                选择银行卡
            </div>
            <div class="am-u-sm-2" style="color: #fff;font-size: 13px;text-align: center;">
                <a href="addx1.html">
                    <img src="img/add.png" alt="" style="width: 20px;" />
                </a>
            </div>
        </div>
    </header>
    <div style="clear: both;"></div>
    <div class="am-u" id="yh_list" style="padding: 0 10px;">
        <!--                        <div class="am-u-sm-12" style="padding: 10px;background: #4C85F6;margin-top: 3%;">
                                <a href="">
                                        <div class="am-u-sm-4" style="text-align: center;">
                                                <img src="img/credit@2x.png" style="width:50px;" alt="" />
                                        </div>
                                        <div class="am-u-sm-8">
                                                <div style="color: #fff;font-size: 14px;">
                                                        平安银行
                                                </div>
                                                <div style="font-size: 14px ;color: #fff;">
                                                        *** *** **** 1432
                                                </div>
                                                <div style="font-size: 14px;color: #fff;">
                                                        账单日:<span id="statement_date">10</span>&nbsp;&nbsp; &nbsp;   还款日: <span id="repayment_date">28</span>
                                                </div>
                                                <div style="font-size: 14px;text-align: right;padding-right: 3%;">
                                                        <a href="yinhang.html" style="color:#fff;">预约列表</a>
                                                </div>
                                        </div>
                                </a>
                        </div>-->
    </div>
    <div class="tcdPageCode" style="margin-top:10px;clear:both;color: red;text-align: center;"></div>


    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/mobile/layer.js"></script>
    <script src="js/jquery.page.js"></script>
    <script src="js/loading.js"></script>
    <script>
        var token1 = sessionStorage.getItem("token");
        var method1 = "Bankcredit|get_list";
        //          第几页
        var p1 = 1;
        //          每页几条数据
        var pagesize1 = 5;
        $.ajax({
            type: 'POST',
            url: "http://www.rice.com/app/api/h5_access",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            datatype: "JSON",
            data: {
                method: method1,
                token: token1,
                p: p1,
                pagesize: pagesize1
            },
            success: function (data) {
                var data1 = JSON.parse(data);
                if (data1.status === 1) {
                    var html = "";
                    for (var i in data1.data.credit) {
                        html += "<div class='am-u-sm-12 hh gradien-bg-x' data='" + data1.data.credit[i].bank_credit_id +
                            "' style='padding: 10px;margin-top: 3%;border-radius:10px;'><a><div class='am-u-sm-4' style='text-align: center;'><img src='" +
                            data1.data.credit[i].logo_url +
                            "' style='width:70px;'/></div><div class='am-u-sm-8'>";
                        html += "<div style='color: #fff;font-size: 14px;' class='card'>" + data1.data.credit[
                            i].cardName + "</div>";
                        html +=
                            "<div style='font-size: 14px ;color: #fff;'>*** *** **** <span class='cardAfter'>" +
                            data1.data.credit[i].cardAfterFour + "</span></div>";
                        html +=
                            "<div style='font-size: 14px;color: #fff;'>账单日:<span class='statement_date'>" +
                            data1.data.credit[i].statement_date +
                            "</span>&nbsp;&nbsp; &nbsp;   还款日: <span class='repayment_date'>" + data1.data.credit[
                                i].repayment_date + "</span></div>";
                        html += "</div></a></div>";
                    }
                    if (html == "") {
                        $("#yh_list").html(
                            "<div style='width:60%;margin:20px 20%;clear:both;'><img src='img/roun.png' style='width:100%;'></div>"
                        );
                        $(".tcdPageCode").css("display", "none");
                    } else {
                        $("#yh_list").html(html);
                    }
                    var r = data1.data.total;
                    r = Math.ceil(r / pagesize1);
                    $(".tcdPageCode").createPage({
                        pageCount: r,
                        current: 1,
                        backFn: function (pagesize1) {}
                    });
                    $(".hh").on("click", function () {
                        sessionStorage["bank_credit_id"] = $(this).attr("data");
                        var t = confirm("是否删除信用卡");
                        if (t) {
                            layer.open({
                                type: 1,
                                offset: 'b',
                                content: '<div style="width:200px;height:120px;"> <h2 style="text-align:center;">确认密码</h2><input type="password" style="border:1px solid #ccc;width:90%;height:35px;line-height:33px;margin-left:5%;" class="" name="pwd" id="pay_pwd" placeholder="请输入支付密码"/><button type="button" class="am-btn pay_btn" style="width:80%;height:35px;line-height:33px;border:0;">确认</button></div>',
                                btn: '关闭全部',
                                btnAlign: 'c',
                                shade: 1,
                                yes: function () {
                                    layer.closeAll();
                                }
                            });
                            $('.pay_btn').click(function () {
                                var token1 = sessionStorage.getItem("token");
                                var method1 = "Bankcredit|del";
                                var pay_pwd = $("#pay_pwd").val();
                                var bank_credit_id = sessionStorage.getItem(
                                    "bank_credit_id");
                                var d = {};
                                d.token = token1;
                                d.method = method1;
                                d.pay_pwd = pay_pwd;
                                d.bank_credit_id = bank_credit_id;
                                $.ajax({
                                    type: 'post',
                                    url: "http://www.rice.com/app/api/h5_access",
                                    data: d,
                                    dataType: 'json',
                                    success: function (result) {
                                        var data1 = JSON.parse(result);
                                        if (data1.status == "1") {
                                            alert(data1.msg);
                                        } else {
                                            return false;
                                        }
                                    }
                                });
                            });


                        }

                    });
                } else if (Number(data1.status) == 2) {
                    alert(data1.message);
                    window.location.href = "login.html";
                } else {
                    alert(data1.message);
                }
            }
        });
        $(".tcdPageCode").on("click", 'a', function () {
            var h = $(this).html();
            if (h == "下一页") {
                var t = $('.tcdPageCode  span.current').html();
                t = parseInt(t);
                p1 = t + 1;
            } else if (h == "上一页") {
                var t = $('.tcdPageCode  span.current').html();
                t = parseInt(t);
                p1 = t - 1;
            } else {
                h = parseInt(h);
                p1 = h;
            }
            $.ajax({
                type: 'POST',
                url: "http://www.rice.com/app/api/h5_access",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                datatype: "JSON",
                data: {
                    method: method1,
                    token: token1,
                    p: p1,
                    pagesize: pagesize1
                },
                success: function (data) {
                    var data1 = JSON.parse(data);
                    if (data1.status === 1) {
                        var html = "";
                        for (var i in data1.data.credit) {
                            html += "<div class='am-u-sm-12 hh' data='" + data1.data.credit[i].bank_credit_id +
                                "' style='padding: 10px;background: #4C85F6;margin-top: 3%;'><a><div class='am-u-sm-4' style='text-align: center;'><img src='" +
                                data1.data.credit[i].logo_url +
                                "' style='width:70px;'/></div><div class='am-u-sm-8'>";
                            html += "<div style='color: #fff;font-size: 14px;' class='card'>" +
                                data1.data.credit[i].cardName + "</div>";
                            html +=
                                "<div style='font-size: 14px ;color: #fff;'>*** *** **** <span class='cardAfter'>" +
                                data1.data.credit[i].cardAfterFour + "</span></div>";
                            html +=
                                "<div style='font-size: 14px;color: #fff;'>账单日:<span class='statement_date'>" +
                                data1.data.credit[i].statement_date +
                                "</span>&nbsp;&nbsp; &nbsp;   还款日: <span class='repayment_date'>" +
                                data1.data.credit[i].repayment_date + "</span></div>";
                            html +=
                                "<div style='font-size: 14px;text-align: right;padding-right: 3%;'><a href='yinhang.html' style='color:#fff;'>预约列表</a></div></div></a></div>";
                        }
                        $("#yh_list").html(html);
                        var r = data1.data.total;
                        r = Math.ceil(r / pagesize1);
                        $(".tcdPageCode").createPage({
                            pageCount: r,
                            current: p1,
                            backFn: function (pagesize1) {}
                        });
                        $(".hh").on("click", function () {
                            sessionStorage["bank_credit_id"] = $(this).attr("data");
                            sessionStorage["cardName"] = $(this).find(".card").html();
                            sessionStorage["cardAfterFour"] = $(this).find(".cardAfter").html();
                            sessionStorage["hh"] = 2;
                            window.location.href = "recharge.html";
                        })
                    } else if (Number(data1.status) == 2) {
                        alert(data1.message);
                        window.location.href = "login.html";
                    } else {
                        alert(data1.message);
                    }
                }
            });
        })
    </script>
</body>

</html>